package com.jz.community.moduleshoppingguide.neighbor.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.utils.RxDataTool;
import com.jz.community.moduleshoppingguide.R;
import com.jz.community.moduleshoppingguide.neighbor.bean.NearCircleListBean;

import java.util.List;


public class NearCircleAdapter extends BaseQuickAdapter<NearCircleListBean.EmbeddedBean.ContentBean, BaseViewHolder> {

    public NearCircleAdapter(int layoutResId, @Nullable List<NearCircleListBean.EmbeddedBean.ContentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, NearCircleListBean.EmbeddedBean.ContentBean entity) {
        //社区名字
        TextView comm_name = helper.getView(R.id.tv_nearby_circle_name);
        comm_name.setText(entity.getCircleName());

        //用户人数
        TextView comm_num = helper.getView(R.id.tv_nearby_circle_user_count);
        comm_num.setText(entity.getUserNum() + "位用户");

        //距离
        TextView comm_dis = helper.getView(R.id.tv_nearby_circle_dis);
        //距离
        float dis = RxDataTool.stringToFloat(entity.getDistance());
        if (dis < 1000) {
            String dis_1 = RxDataTool.getRoundUp(dis + "", 0);
            comm_dis.setText("距" + dis_1 + "m");
        } else {
            String dis_1 = RxDataTool.getRoundUp(dis / 1000 + "", 0);
            comm_dis.setText("距" + dis_1 + "km");
        }

        helper.addOnClickListener(R.id.tv_add_nearby_circle);

    }
}
